"""
信号整流
1.不同信号  整流一个  只关心真假 或是值
 多源True False  多源异值
2.同一个信号  不同状态的整流
"""
from jili.core.printlog import print
class signal_rectification:
    def __init__(self,signals):
        self.signals=signals
        self.pre_True_flag=None
    def oncalc(self,b,timekey=None):
        flag=None
        for k,v in self.signals.items():
            a=b.get(k,None)
            if a==v:
                if k!=self.pre_True_flag:
                    flag=k
                    self.pre_True_flag=k
                    break
        return flag
class signal_rectification_byonesource:
    def __init__(self, signal_key,signal_value):
        self.signal_key = signal_key
        self.signal_value=signal_value
        self.pre_True = None

    def oncalc(self, b,timekey=None):
        flag=None
        a = b.get(self.signal_key, None)
        if a in self.signal_value:
            if a!=self.pre_True:
                flag = a
                self.pre_True_flag = a
        return flag